//	 ID : pallab81
// 	PROG : 3291_1
// 	LANG : C++
// 	2011-10-13-08.10.22 Thursday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait( double seconds ){
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ){
        ;
    }
}
int cases=1;
int N;
vector<int> team;
inline void Read(){
        team.assign(N,0);
        fo(i,N){
            scanf("%d",& team[i]);
        }
}
inline void Proc(){
        sort( team.begin(), team.end(), less<int>() );
        Int sum=0;
        for(int i=0;i<N;++i){
            int id = upper_bound(team.begin(), team.end(), team[i] ) - team.begin();
            int var = N-id;
            sum = sum + (int)var;

        }
        printf("Case %d: %lld\n",cases,sum);
        ++cases;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("in","rt",stdin);
	#endif

    while( scanf("%d",&N)==1 ){
        if( N==0 )break;
        Read();
        Proc();
    }


return 0;
}
